package com.m.complex

import com.m.AbstractRule
import com.m.rule.AbstractDim

/**
 * 功能: 组合规则<br/>
 *
 * @author miracle
 */
abstract class CombinationRule extends AbstractRule{
    /**
     * 子规则集合
     */
    def operatorRules = []
    def name

    CombinationRule(String name) {
        super(name.concat("组合规则"))
        this.name = name.concat("组合规则")
    }

    @Override
    boolean hitRule(AbstractDim abstractDim) {
        if (operatorRules.size() == 0) {
            return false
        }

        return multiHitRule(abstractDim)
    }

    abstract boolean multiHitRule(abstractDim)

    /**
     * 添加算子规则
     * @param iRule
     * @return
     */
    def addOperatorRule(iRule) {
        operatorRules.add(iRule)
    }

    @Override
    String toString() {
        return "组合规则".concat(this.name)
    }
}
